package com.example.demo.service.impl;

import com.example.demo.mapper.EChartsMapper;
import com.example.demo.service.EChartsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class EChartsServiceImpl implements EChartsService {

    @Autowired
    private EChartsMapper eChartsMapper;


    @Override
    public Double[] findValueByYear(Integer year, String place) {
        Double[] yearValue = new Double[4];
        yearValue[0] = eChartsMapper.findValueByYearSeasonPlace(year, 1,place);
        yearValue[1] = eChartsMapper.findValueByYearSeasonPlace(year, 2,place);
        yearValue[2] = eChartsMapper.findValueByYearSeasonPlace(year, 3,place);
        yearValue[3] = eChartsMapper.findValueByYearSeasonPlace(year, 4,place);
        return yearValue;
    }

    @Override
    public Double[] plusValueByYear(Integer year, String place) {
        Double[] yearPlusValue = new Double[4];
        yearPlusValue[0] = eChartsMapper.findValueByYearSeasonPlace(year, 1,place);
        yearPlusValue[1] = eChartsMapper.findValueByYearSeasonPlace(year, 2,place) +yearPlusValue[0];
        yearPlusValue[2] = eChartsMapper.findValueByYearSeasonPlace(year, 3,place)+yearPlusValue[1];
        yearPlusValue[3] = eChartsMapper.findValueByYearSeasonPlace(year, 4,place)+yearPlusValue[2];

        return yearPlusValue;
    }
}
